
section	.text

	;; These are the C handlers for the exceptions.
	;; For now they only call a panic routine.

extern __idt_interrupt_0
extern __idt_interrupt_1
extern __idt_interrupt_3
extern __idt_interrupt_4
extern __idt_interrupt_5
extern __idt_interrupt_6
extern __idt_interrupt_7
extern __idt_interrupt_8
extern __idt_interrupt_9
extern __idt_interrupt_10
extern __idt_interrupt_11
extern __idt_interrupt_12
extern __idt_interrupt_13
extern __idt_interrupt_14
extern __idt_interrupt_16

extern __kernel_panic
	
	;; The NULL ISR routine. Does nothing for now.
global __isr_null
__isr_null:
	call	__kernel_panic
	iret


	;; Divide error
global	__isr0
__isr0:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_0

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Debug exception
global	__isr1
__isr1:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_1

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Intel Reserved
global	__isr2
__isr2:
	iret

	;; Breakpoint
global	__isr3
__isr3:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_3
	
	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Overflow
global	__isr4
__isr4:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_4

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Bounds check
global	__isr5
__isr5:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_5

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Invalid opcode
global	__isr6
__isr6:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_6

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Coprocessor not available
global	__isr7
__isr7:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_7

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Double fault
global	__isr8
__isr8:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_8

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Coprocessor segment overrun
global	__isr9
__isr9:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_9

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Invalid TSS
global	__isr10
__isr10:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_10

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Segment not present
global	__isr11
__isr11:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_11

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Stack exception
global	__isr12
__isr12:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_12

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; General protection exception
global	__isr13
__isr13:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_13

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Page fault
global	__isr14
__isr14:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_14

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret

	;; Intel reserved
global	__isr15
__isr15:
	iret


	;; Coprocessor error
global	__isr16
__isr16:
	pusha
	push gs
	push fs
	push ds
	push es

	call __idt_interrupt_16

	pop es
	pop ds
	pop fs
	pop gs
	popa
	iret
